package org.example.wikwok.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.example.wikwok.pojo.User;
import org.springframework.stereotype.Repository;

@Repository
public interface UserMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    @Select("SELECT * FROM user WHERE name=#{name};")
    List<User> selectByName(String name);

    @Select("SELECT id FROM user WHERE name=#{name};")
    int selectIdByName(String name);

    @Select("""
            SELECT u.*
            FROM user u
                     JOIN `follow` fo ON u.id = fo.followedUserId
            WHERE fo.followerUserId = #{userId};""")
    List<User> selectlikedUpMaster(int userId);
}